<style>
    #blackList-update {
        padding: 20px 25px 25px 0;
    }
</style>
<div class="layui-fluid" id="blackList-update">
    <form class="layui-form" action="" lay-filter="blackList-update-form">
        <div class="layui-form-item website-hide">
            <label class="layui-form-label website-form-item-require">id：</label>
            <div class="layui-input-block">
                <input type="text" name="blackListId" data-th-value="${blackList.blackListId}">
            </div>
        </div>
        <div class="layui-form-item ">
            <div class="layui-row">
                <div class="layui-col-md6">
                    <label class="layui-form-label website-form-item-require">姓名：</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-md6">
                    <label class="layui-form-label website-form-item-require">证件类型：</label>
                    <div class="layui-input-block">
                        <select name="identityTypeCode" lay-filter="identityTypeCode" lay-verify="required" id="identityTypeCode">
                            <option value="">请选择</option>
                            <option
                                    th:each="item : ${zjlxList}"
                                    th:value="${item.code}" th:text="${item.name}">
                            </option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item ">
            <div class="layui-row">
                <div class="layui-col-md6">
                    <label class="layui-form-label website-form-item-require">证件号：</label>
                    <div class="layui-input-block">
                        <input type="text" id="identityId" name="identity" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-row">
                <div class="layui-col-md12">
                    <label class="layui-form-label website-form-item-require">加入黑名单原因：</label>
                    <div class="layui-input-block">
                        <textarea name="reason" lay-verify="required" placeholder="请输入内容" rows="5" class="layui-textarea"></textarea>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item website-hide">
            <button class="layui-btn" lay-submit="" lay-filter="blackList-update-form-submit" id="submit"></button>
        </div>
    </form>
</div>

<script data-th-inline="javascript">
    layui.use(['website', 'form', 'formSelects', 'validate'], function () {
        var $ = layui.$,
            website = layui.website,
            layer = layui.layer,
            formSelects = layui.formSelects,
            form = layui.form,
            blackList = [[${blackList}]],
            $view = $('#blackList-update'),
            validate = layui.validate;
        form.verify(validate);
        form.render();
        initBlackListValue();
        formSelects.render();
        function initBlackListValue() {
            form.val("blackList-update-form", {
                "blackListId": blackList.blackListId,
                "name": blackList.name,
                "identityTypeCode": blackList.identityTypeCode,
                "identity": blackList.identity,
                "reason": blackList.reason
            });
            var code=$('#identityTypeCode').val();
            if ("zjlx_sfz" === code) {
                $('#identityId')[0].setAttribute('lay-verify', "required|identityNumber")
            }else {
                $('#identityId')[0].setAttribute('lay-verify', "required")
            }
        }
        form.on('select(identityTypeCode)', function (data) {
            if ("zjlx_sfz" === data.value) {
                $('#identityId')[0].setAttribute('lay-verify', "required|identityNumber")
            }else {
                $('#identityId')[0].setAttribute('lay-verify', "required")
            }
        });

        form.on('submit(blackList-update-form-submit)', function (data) {
            website.post(ctx + 'blackList/update', data.field, function () {
                layer.closeAll();
                website.alert.success('数据修改成功');
                $('#website-blackList').find('#query').click();
            });
            return false;
        });

    });
</script>